import BILL_FIELD_EDIT_CONFIG from '@/config/bill_field_edit_config'
import type { BillFieldTypeKey } from '@/config/bill_field_edit_config'
import { getFieldEditEnable } from '@/js/typeMiddleware'
import type { BillGenerateField } from '@/config/common_type_config/type'

export const useBillFieldEdit = (billType: BillFieldTypeKey): {
	billTypeEnum: BillTypeEnum
	getFieldEditEnable: Function
} => {
	const billTypeEnum = BILL_FIELD_EDIT_CONFIG[billType].billFieldEnum
	const getFieldEditEnableHandler = (billType: BillFieldTypeKey) => {
		return (field: string, billGenerateField: BillGenerateField) => {
			return getFieldEditEnable(billType, field, billGenerateField)
		}
	}
	return {
		billTypeEnum,
		getFieldEditEnable: getFieldEditEnableHandler(billType)
	}
}
